package com.example.myapplication.DataBase;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.example.myapplication.Person;
import java.util.ArrayList;

public class SqlLiteHelper extends SQLiteOpenHelper {
  private static final String DataBASE_Name = "myDatabase.db";
  private static final int DATABASE_VERSION=1;
  private SQLiteDatabase database;
  public SqlLiteHelper(Context context) {
    super(context,DataBASE_Name,null,DATABASE_VERSION);
    database=this.getWritableDatabase();
  }
  public SqlLiteHelper(Context context,String name, SQLiteDatabase.CursorFactory factory,int version) {
    super(context,name,factory,version);

  }
  public SqlLiteHelper(Context context, String name){
    super(context,name,null,DATABASE_VERSION);
  }


  @Override public void onCreate(SQLiteDatabase db) {
    //创建数据库表
    db.execSQL("create table user(name  varchar(20) PRIMARY KEY,job varchar(20))");
  }

  @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    String dropTableQuery = "DROP TABLE IF EXISTS user";
    db.execSQL(dropTableQuery);
    onCreate(db);
  }

}
